<template>
	<view class="index" style="padding: 0;">
		<block v-if="storeRankList.length">
			<view class="index-item index-item-4" style="margin: 0; border-radius: 0; padding-top: 0;">
				<view class="index-item-4-list">
					<view class="index-item-4-tit" style="margin: 0; padding: 30rpx 0 0;">
						<text>序号</text>
						<text>LOGO</text>
						<text>名称</text>
						<text>总金额(元)</text>
					</view>
					<view>
						<view class="index-item-4-item" v-for="(data,index) in storeRankList" :key="index">
							<view><text v-if="index<9">0</text>{{index+1}}</view>
							<view>
								<image :src="data.store.store_logo?data.store.store_logo:'https://master.shengejiaju.cn/web/static/icons/shop-default.png'" mode="aspectFill"></image>
							</view>
							<view>{{data.store.store_name?data.store.store_name:'未设置店铺名称'}}</view>
							<view>{{data.money}}</view>
						</view>
					</view>
				</view>
			</view>
			<no-more :text="'数据加载完毕'" v-if="storeRankList.length && noMore"></no-more>
		</block>
		<block v-else>
			<nothing :text="'暂无数据'" :btn="false"></nothing>
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 0,
				noMore: false,
				storeRankList: []
			};
		},
		onLoad() {
			this.getStoreRank()
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.getStoreRank(this.page)
			}
		},
		methods: {
			// 获取店铺排行榜
			getStoreRank(page){
				this.$api.OrderListData({limit: 20,page: page?page:0, day: 1,goods_store_id: 1}).then(res => {
					if(res.datas.list.length){
						res.datas.list.forEach(item => {
							this.storeRankList.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import '../../static/scss/index.scss';
</style>